﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WiiGeeDotNet.filter
{
  public abstract class Filter
  {

    public Filter()
    {
      // nothing, but should be called via SUPER.
    }

    public void Reset()
    {
      // reset filter, if necessary.
    }


    /// <summary>
    /// The actual called method to filter anything. It checks if the vector is
    /// already set to NULL by another filter and won't process it anymore. If it's
    /// not NULL it would be forwarded to the actual implemented method - filterAlgorithm(). 
    /// </summary>
    /// <param name="_vector">The acceleration vector, encoding: 0/x, 1/y, 2/z</param>
    /// <returns>a new, filtered acceleration vector, encoded the same way</returns>
    public virtual double[] FilterVector(double[] _vector)
    {
      if (_vector == null)
      {
        return null;
      }
      else
      {
        return FilterAlgorithm(_vector);
      }
    }

    /***
     * A filter receives a triple of acceleration values within the variable 'vector'.
     * It's encoded as vector[0]=x, vector[1]=y, vector[2]=z. This is not an object since the
     * processing of the filter should be really fast, since every acceleration of the wiimote
     * passes the filter.
     * @param vector
     * @param absvalue
     * @return
     */
    abstract public double[] FilterAlgorithm(double[] vector);

  }

}
